import subprocess

# readers = input("Reader Nodes: ")
# partitions = input("Partition Nodes: ")
# mode = input("Mode(bandwidth or latency): ")

readers = ["", "", ""]
partitions = ["", "", ""]
mode = "bandwidth" # bandwidth or latency

result = {}
for r in readers:
    result[r] = {}

def output(nodes):
    for p in partitions:
        print("\t" + nodes[p], end="")
    print()
    for r in readers:
        print(nodes[r], end="")
        for p in partitions:
            print("\t" + result[r][p], end="")
        print()

def run(cmd: str) -> str:
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
    process.wait()
    return str(process.stdout.read())[2:-3]

def test():
    for r in readers:
        for p in partitions:
            cmd = "./util.sh " + mode + " " + r + " " + p
            out = run(cmd)
            print(r + " --> " + p + " : " + out)
            result[r][p] = out

test()
nodes = {"": "node0", "": "node1", "": "node2"}
output(nodes)
